using System;

namespace GeoAzure.Core.Tests
{
    public static class TestObjectFactory
    {
        public static Location[] CreateRandomLocations(int count)
        {
            var result = new Location[count];
            var random = new Random();
            for (int i = 0; i < count; i++)
            {
                result[i] = Location.FromDegrees((random.NextDouble() - 0.5) * 180.0, (random.NextDouble() - 0.5) * 360.0);
            }
            return result;
        }

        public static IBounded[] CreateBoundedObjects(int count)
        {
            var result = new IBounded[count];
            var random = new Random();
            for (int i = 0; i < count; i++)
            {
                var long1 = (random.NextDouble() - 0.5) * 360d;
                var long2 = (random.NextDouble() - 0.5) * 360d;
                var lat1 = (random.NextDouble() - 0.5) * 180d;
                var lat2 = (random.NextDouble() - 0.5) * 180d;

                result[i] = new Bounded(GeoRectangle.Create(Location.FromDegrees(Math.Max(lat1, lat2), Math.Min(long1, long2)), Location.FromDegrees(Math.Min(lat1, lat2), Math.Max(long1, long2))));
            }
            return result;
        }

        public static IBounded[] CreatePointBoundedObjects(int count)
        {
            var result = new IBounded[count];
            var random = new Random();
            for (int i = 0; i < count; i++)
            {
                var long1 = (random.NextDouble() - 0.5) * 360d;
                var lat1 = (random.NextDouble() - 0.5) * 180d;

                result[i] = new Bounded(GeoRectangle.Create(Location.FromDegrees(lat1, long1), Location.FromDegrees(lat1, long1)));
            }
            return result;
        }
    }
}